package tests;

import static org.junit.Assert.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class HighScoreTest {

	private static fallingGame.HighScore h;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		h = new fallingGame.HighScore();
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
		h = null;
	}

	@Test
	public final void testSort() {
		Object[][] o1 = { { "A", 1 }, { "B", 198654 }, { "C", 145 },
				{ "D", 9854 } }; // actual
		Object[][] o2 = { { "B", 198654 }, { "D", 9854 }, { "C", 145 },
				{ "A", 1 } }; // expected
		o1 = h.sort(o1, 1);
		assertArrayEquals(o2[0], o1[0]);
		assertArrayEquals(o2[1], o2[1]);
	}

	@Test
	public final void testSaveHighScore() {
		h.saveHighScore("Test", 1000); // save test score
	}

	@Test
	public final void testShowHighScores() {
		/*
		 * Creating a new HighScore() so the test score that is saved in the
		 * previous test will show in the high score table.
		 */
		new fallingGame.HighScore().showHighScores();
	}
	
	@Test
	public final void testClearHighScores(){
		new fallingGame.HighScore().clearHighScores(); // clear table
		new fallingGame.HighScore().showHighScores(); // show cleared table
	}
}
